/**
 * 管理员的注册
 */
package controller;

import hibernate.Adminstab;
import hibernate.AdminstabDAO;
import hibernate.HibernateSessionFactory;
import hibernate.Parkstab;
import hibernate.ParkstabDAO;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

public class RegisterSuccess implements Action {
	private String account;
	private String pwd;
	private String name;
	private String telNUmber;
	private String mail;
	//int parkUUID;
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getPwd() {
		return pwd;
	}
	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getTelNUmber() {
		return telNUmber;
	}
	public void setTelNUmber(String telNUmber) {
		this.telNUmber = telNUmber;
	}
	public String getMail() {
		return mail;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
//	public int getParkUUID() {
//		return parkUUID;
//	}
//	public void setParkUUID(int parkUUID) {
//		this.parkUUID = parkUUID;
//	}

	public String execute(){
		AdminstabDAO adminstabDAO=new AdminstabDAO();
		adminstabDAO.getSession().beginTransaction();
		try
		{
			Adminstab adminstab = new Adminstab();
			adminstab.setAccount(getAccount());
			adminstab.setPwd(getPwd());
			adminstab.setName(getName());
			adminstab.setTelNumber(getTelNUmber());
			adminstab.setMail(getMail());
			//ParkstabDAO parkstabDAO = new ParkstabDAO();
			//Parkstab parkstab = parkstabDAO.findById(getParkUUID());
			//adminstab.setParkstab(parkstab);

			adminstabDAO.attachDirty(adminstab);
			adminstabDAO.getSession().getTransaction().commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			adminstabDAO.getSession().close();
		}


		System.out.println("管理员添加成功");

		return SUCCESS;
	}
}
